package service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import entity.HService;
import entity.LayRequest;
import mapper.ServiceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author lay
 * @date 2020/6/22 10:55
 */
@Service
public class ServiceServiceImpl  implements ServiceService{
    @Autowired
    private ServiceMapper serviceMapper;


    @Override
    public List<HService> selectAll() {
        return null;
    }

    @Override
    public int insert(HService hService) {
        return serviceMapper.insert(hService);
    }

    @Override
    public void batchDelete(Integer[] ids) {
         serviceMapper.batchDelete(ids);
    }

    @Override
    public int delete(Integer id) {
        return 0;
    }

    @Override
    public HService selectById(Integer id) {
        return serviceMapper.selectById(id);
    }

    @Override
    public int update(HService hService) {
        return serviceMapper.update(hService);
    }

    /*@Override
    public PageInfo<HService> selectByPage(Map<String, Object> map) {
        return null;
    }*/

    @Override
    public PageInfo<HService> selectByPage(LayRequest layRequest) {
        //1.设置当前页，和每页记录条数
        PageHelper.startPage(layRequest.getPage(),layRequest.getLimit());
        //2.执行查询语句，startPag之后的第一个查询会默认进行分页
        List<HService> services = serviceMapper.selectByMap(layRequest.getParams());
        //3.创建PageInfo对象，并将返回结果传入，会自赋值，总记录数当前页等数据
        PageInfo<HService> servicePageInfo = new PageInfo<>(services);
        return servicePageInfo;
    }
}
